package com.mms.controller;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.github.pagehelper.Page;
import com.mms.dao.IUserInfoDao;
import com.mms.pojo.RoleInfo;
import com.mms.service.IRoleInfoService;
import com.mms.service.IUserInfoService;
import com.mms.utils.LayUiPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 陈林鹏
 * @since 2021-04-14
 */
@Controller
@RequestMapping("/roleInfo")
public class RoleInfoController {

    @Autowired
    IRoleInfoService roleInfoService;

    @Autowired
    IUserInfoService userInfoService;

    @Autowired
    IUserInfoDao userInfoDao;

    /**
     * 获取 角色信息
     *
     * @return
     */
    @RequestMapping(value = "getRoleInfo")
    public ModelAndView getRoleInfoHtml() {
        //分页
        Page page = LayUiPage.maxPage();

        //查询
        List<RoleInfo> roleInfos = roleInfoService.selectList(new EntityWrapper<>());
        ModelAndView mv = new ModelAndView();

        mv.addObject("roleInfos", roleInfos);
        mv.setViewName("CreateUserInfo");
        //关闭分页
        page.close();
        //返回
        return mv;
    }

    @RequestMapping(value = "getRoleInfoParent")
    public ModelAndView getRoleInfoHtmlParent() {
        //设置最大数量
        Page page = LayUiPage.maxPage();

        //查询所有非用户角色
        List<RoleInfo> roleInfos = roleInfoService.selectList(new EntityWrapper<>());
        //设置视图
        ModelAndView mv = new ModelAndView();
        //设置传参
        mv.addObject("roleInfos", roleInfos);
        //设置 转发的jsp页面
        mv.setViewName("ModifyRoles");
        //关闭分页
        page.close();
        return mv;
    }

}

